fix: restructure artifacts directory for $ref consumption#606
fix: restructure artifacts directory for $ref consumption#606rartych merged 18 commits intocamaraproject:mainfrom
Conversation
…ect#603) Phase 1 of artifacts restructuring: - Move CAMARA_common.yaml to artifacts/common/ directory - Add api-templates/sample-service.yaml demonstrating $ref consumption - Update documentation references to new path The sample-service template demonstrates two patterns for error responses: - Option A: pure $ref for responses using only generic error codes - Option B: local response definition extending generic errors with API-specific codes (ResourceNotFound404 example) Next steps (after camaraproject#604 merges): - Add CAMARA_event_common.yaml with CloudEvent/Source/DateTime schemas - Add notification-templates/sample-notification.yaml - Add event-related API templates (implicit events, subscriptions) - Migrate camara-cloudevents/ content to new structure
…onsumption - Add artifacts/common/CAMARA_event_common.yaml with CloudEvents envelope, subscription management, protocol settings, credentials, lifecycle data, and subscription-specific error responses - Add artifacts/api-templates/sample-service-subscriptions.yaml (624 lines, down from 1397 — 55% reduction via $ref to common files) - Add artifacts/notification-templates/sample-notification.yaml (77 lines, replacing 345-line notification-as-cloud-event.yaml) - Add DateTime schema to CAMARA_common.yaml - Switch common files to components-only format (no openapi/paths stub) - Move event-subscription-template.feature to artifacts/testing/ - Remove notification-as-cloud-event.yaml and camara-cloudevents/ directory - Update README.md with new directory structure
Design note: boundary between
|
- sample-service.yaml: title without "API", add externalDocs, fix apiRoot description, add pagination (minItems/maxItems), add maxLength to UUID - CAMARA_common.yaml: add description to openId securityScheme - sample-service-subscriptions.yaml: openId via $ref to CAMARA_common.yaml
|
Thanks @rartych for the review! All suggestions applied in the latest push:
Additional fixes found during Design Guide compliance check:
|
Comment out MQTT3, MQTT5, AMQP, NATS, KAFKA protocol references in both sample-service-subscriptions.yaml and CAMARA_event_common.yaml. Comments signal future extensibility; bundled output is now HTTP-only. Changes: - Protocol enum: converted to block sequence, only HTTP active - Discriminator mappings: only HTTP mapping active - Protocol-specific schemas: 8 non-HTTP schemas commented out - Settings schemas: MQTTSettings, AMQPSettings, ApacheKafkaSettings, NATSSettings commented out, HTTPSettings remains Validated on camaraproject/ReleaseTest#64 (bundling + yamllint + spectral).
…mon.yaml No api-name placeholders, identical across all subscription APIs. Template now uses $ref to common file, matching the openId pattern.
Comment out PLAIN enum value, discriminator mapping, and PlainCredential schema in CAMARA_event_common.yaml. The description already states that only ACCESSTOKEN and PRIVATE_KEY_JWT are supported.
tanjadegroot
left a comment
There was a problem hiding this comment.
redefine TimePeriod to use $ref to DateTime
Per review discussion — replace inline date-time definitions with $ref to the DateTime schema. Move endDate optionality note to the TimePeriod object description.
@tanjadegroot Done in 9bbd0bf. Thanks for the final proposal, moving the description up was the solution. |
Replace all functional api-name/apiName placeholders with concrete values matching the template filename, consistent with sample-service.yaml which already uses concrete names. This makes the template a valid, lintable OpenAPI spec. Replacements: - Event types: org.camaraproject.sample-service-subscriptions.v0.* - Server URL: sample-service-subscriptions/vwip - Security scopes: sample-service-subscriptions:* - Tags: Sample Service Subscription - operationIds: createSampleServiceSubscription etc. - Summaries/descriptions: sample service
Add Generic400 error responses to GET /resources, GET /resources/{resourceId},
and DELETE /resources/{resourceId}. POST /resources already had 400.
Addresses OWASP API8 validation warning (define-error-validation).
There was a problem hiding this comment.
great work @hdamker!
Looks fine. Some minor suggestions and one clarification doubt.
I think also CAMARA-API-Event-Subscription-and-Notification-Guide.md needs to be updated regarding some links and file names, according to this artifacts refactor
E.g.:
Section 2.2. Resource-based (Explicit) Subscription ->
A generic neutral CloudEvent subscription OpenAPI specification is available in Commonalities/artifacts/camara-cloudevents directory (event-subscription-template.yaml).
- Add backtick formatting for endDate in TimePeriod description - Add template usage clarification note to sample-service-subscriptions - Update 6 stale artifact path references in Event Subscription and Notification Guide to match restructured directory layout
@PedroDiez done in 58a0902, please check if there are further occurrences. |
|
@hdamker One comment/observation I would like to make apart from the review. In some of the artifacts, the are the same common references replicated N-times for different fields As an example, in parameters:
- $ref: "../common/CAMARA_common.yaml#/components/parameters/x-correlator"Other way would be to define a "common local schema" in the file for Maybe you have seen this way better for latter applying the bundling (just in case) |
PedroDiez
left a comment
There was a problem hiding this comment.
LGTM in advance
Minor comment for wording aligment
@PedroDiez the bundling will do the deduplication. In the bundle there will be exactly one ("common") definition for the parameter |
Adds sample-implicit-events.yaml under artifacts/api-templates/ as the canonical template for CAMARA APIs that deliver event notifications via OpenAPI callbacks on a resource-creation operation, with no dedicated /subscriptions sub-API (implicit-subscription pattern). Follows the post-camaraproject#604 layered event-schema architecture: pure CloudEvent envelope referenced from CAMARA_event_common.yaml, local ApiNotificationEvent that constrains type via ApiEventType and owns the discriminator mapping, concrete event schemas extending ApiNotificationEvent. Companion documentation update to CAMARA-API-Event-Subscription-and-Notification-Guide.md is deferred to a follow-up commit to avoid conflicts with camaraproject#606 doc edits.
|
@camaraproject/commonalities_codeowners please consider to review and approve the PR upfront to todays meeting ... only after it landed in main I can finalize #612 and mark it ready for review. cc: @tanjadegroot |
patrice-conil
left a comment
There was a problem hiding this comment.
Nice job Herbert!
LGTM
thanks for the info @hdamker! |
What type of PR is this?
What this PR does / why we need it:
Restructures the
artifacts/directory for$refconsumption and bundling (#603).Phase 1 — common schemas:
CAMARA_common.yamltoartifacts/common/, addsDateTimeschemaartifacts/api-templates/sample-service.yaml— CRUD template demonstrating$refto common schemasPhase 2 — event and subscription schemas:
artifacts/common/CAMARA_event_common.yaml— CloudEvents envelope, subscription management, protocol settings, credentials, lifecycle data, and subscription-specific error responsesartifacts/api-templates/sample-service-subscriptions.yaml— explicit subscription template rewritten with$ref(624 lines, down from 1397)artifacts/notification-templates/sample-notification.yaml— notification callback template with$ref(77 lines, down from 345)event-subscription-template.featuretoartifacts/testing/notification-as-cloud-event.yamlandcamara-cloudevents/directoryPhase 3 — clean up unused protocol and credential definitions:
sample-service-subscriptions.yamlandCAMARA_event_common.yaml— only HTTP is used in CAMARA, comments signal future extensibilityCommon files use a components-only format (no
openapi/pathsstub) — they are consumed via$ref, not deployed as standalone APIs.Which issue(s) this PR fixes:
Fixes #603
Does this PR introduce a breaking change?
Special notes for reviewers:
Deferred:
sample-implicit-events.yaml(callback-based event pattern template) — tracked as a follow-up issue.All templates validated with
redocly bundle(all$refresolved) andspectral lint(no new errors). Phase 3 changes also validated on ReleaseTest#64 — bundled output contains only HTTP schemas and no PLAIN credential.Changelog input
Additional documentation